const { axios } = require('../../utils/http')
const { formatRichText } = require('../../utils/util')

Page({
  blogDetail: {},
  onShow() {
    console.log('zz')
  },
  onLoad(options) {
    const { id } = options
    this.getBlogDetail(id)
  },
  getBlogDetail(id) {
    axios
      .get('/blog/detail', {
        params: {
          id
        }
      })
      .then(res => {
        let content = formatRichText(res.data.data.content)
        this.setData({
          blogDetail: { ...res.data.data, content }
        })
        wx.setNavigationBarTitle({
          title: res.data.data.title
        })
        console.log(this.data.blogDetail)
      })
  }
})
